package pl.smath.expression.model.presentation;

public enum ExtendedRelationType {

	EQUAL,
	NOT_EQUAL,
	GREATER_THAN,
	GREATER_THAN_OR_EQUAL_TO,
	LESS_THAN,
	LESS_THAN_OR_EQUAL_TO,
	IDENTICAL, EQUVALENT,APPROXIMATELY_EQUAL, ISOMORPHIC, ORTHOGONAL, PARALLEL;

	/**
	 * Convertuje postac tekstowa relacji na typ
	 * @param type
	 * @return
	 */
	public static ExtendedRelationType string2type(String type) {
		
		if(type.compareTo("=") == 0)
			return ExtendedRelationType.EQUAL;
		else if(type.compareTo("!=") == 0)
			return ExtendedRelationType.NOT_EQUAL;
		else if(type.compareTo(">") == 0)
			return ExtendedRelationType.GREATER_THAN;
		else if(type.compareTo(">=") == 0)
			return ExtendedRelationType.GREATER_THAN_OR_EQUAL_TO;
		else if(type.compareTo("<") == 0)
			return ExtendedRelationType.LESS_THAN;
		else if(type.compareTo("<=") == 0)
			return ExtendedRelationType.LESS_THAN_OR_EQUAL_TO;
		else if(type.compareTo("~") == 0)
			return ExtendedRelationType.EQUVALENT;
		else if(type.compareTo("===") == 0)
			return ExtendedRelationType.IDENTICAL;
		else if(type.compareTo("~=") == 0)
			return ExtendedRelationType.APPROXIMATELY_EQUAL;
		else if(type.compareTo("~==") == 0)
			return ExtendedRelationType.ISOMORPHIC;
		else if(type.compareTo("_|_") == 0)
			return ExtendedRelationType.ORTHOGONAL;
		else if(type.compareTo("||") == 0)
			return ExtendedRelationType.PARALLEL;
		
		return null;
	}

	
	/**
	 * Convertuje postac tekstowa relacji na typ
	 * @param type
	 * @return
	 */
	public static String type2string(ExtendedRelationType type) {

		if(type == ExtendedRelationType.EQUAL)
			return "=";
		else if(type == ExtendedRelationType.NOT_EQUAL)
			return "!=";
		else if(type == ExtendedRelationType.GREATER_THAN)
			return ">";
		else if(type == ExtendedRelationType.GREATER_THAN_OR_EQUAL_TO)
			return ">=";
		else if(type == ExtendedRelationType.LESS_THAN)
			return "<";
		else if(type == ExtendedRelationType.LESS_THAN_OR_EQUAL_TO)
			return "<=";
		else if(type == ExtendedRelationType.IDENTICAL)
			return "===";
		else if(type == ExtendedRelationType.EQUVALENT)
			return "~";
		else if(type == ExtendedRelationType.APPROXIMATELY_EQUAL)
			return "~=";
		else if(type == ExtendedRelationType.ISOMORPHIC)
			return "~==";
		else if(type == ExtendedRelationType.ORTHOGONAL)
			return "_|_";
		else if(type == ExtendedRelationType.PARALLEL)
			return "||";
		
		return null;
	}

}
